<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    1-100之和为: <span id="result"></span><br>
    1-100奇数之和为: <span id="result2"></span><br>
    1-100偶数之和为: <span id="result3"></span><br>
    1-100之内能被3整除的数之和: <span id="result4"></span>
    <script>
        var resultObj=document.getElementById("result")
        var sum=0
        var i=0
        do{
            sum+=i;
            i++;
        }while(i<=100)
        resultObj.innerText=sum;

        var result2Obj=document.getElementById("result2")
        var sum2=0
        var i=0
        do{
            sum2+=i;
            i=i+2;
        }while(i<=100)
        result2Obj.innerText=sum2;

        var result3Obj=document.getElementById("result3")
        var sum3=0
        var i=0
        do{
            sum3+=i;
            i=i+2
        }while(i<=100)
        result3Obj.innerText=sum3

        var result4Obj=document.getElementById("result4")
        var sum4=0
        var i=0
        do{
            sum4+=i;
            i=i+3                                 //while循环是先判断是否正确，do while循环是先执行再判断。
        }while(i<=100)                            //break 终止所有循环
        result4Obj.innerText=sum4                 //continue表示跳过本次循环，执行下一个循环。且contineu后面的代码不运行
    </script>   
</body>
</html>